(require '[ca.uoit.molly.lucene-helper :as lucene])
(require '[ca.uoit.molly.lucene-molly :as lucene-molly])
(require '[ca.uoit.molly.db-molly :as db])
(require '[ca.uoit.molly.mycampus :as mycampus])
(require '[ca.uoit.molly.molly-search :as search])
(require '[clojure.contrib.pprint :as pp])

(println "Packages loaded as lucene, lucene-molly, db, mycampus, search")

(doseq [v (search/search-values
            {:phrase "database"
             :topk 5
             :idx search/*value-searcher*})]
  (pp/pprint (select-keys v [:entity :attr :value :__type__])))

(dotimes [_ 3] (println))

(doseq [e (search/search-entities
            {:phrases ["csci 3030u" "database"]
             :attrs []
             :topk 5
             :idx search/*entity-searcher*
             :debug true})]
  (pp/pprint e))

(dotimes [_ 3] (println))

(doseq [e (search/search-entities
            {:attrs [{:name "description" :value "database programming"}]
             :phrases []
             :topk 5
             :idx search/*entity-searcher*
             :debug true})]
  (pp/pprint e))

(dotimes [_ 3] (println))

(doseq [g (search/search-groups
          {:parameters [{:name nil :value "winter 2011"}]
           :topk 3
           :idx search/*group-searcher*
           :debug true
          })]
  (pp/pprint g)
  (println "-------------------"))

(dotimes [_ 3] (println))
(doseq [g (search/search-groups
           {:entities [{:entity "section" :id "3011"}
                       {:entity "course" :id "csci 3030u"}
                       {:entity "schedule" :id "7759"}]
            :topk 5
            :idx search/*group-searcher*
            :debug true
           })]
  (pp/pprint g)
  (println "-------------------"))

(dotimes [_ 3] (println))
(doseq [g (search/search-groups
           {:attrs [{:name "description" :value "database programming"}]
            :topk 5
            :idx search/*group-searcher*
            :debug true
           })]
  (pp/pprint g)
  (println "-------------------"))

